//
//  SegTableViewCell.m
//  Ting
//
//  Created by 安静的美男子 on 14/11/13.
//  Copyright (c) 2014年 安静的美男子. All rights reserved.
//

#import "SegTableViewCell.h"
@implementation SegTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.photo = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, self.contentView.frame.size.width / 320.0 * 80, 90)];
        [self.contentView addSubview:_photo];
        self.title = [[UILabel alloc]initWithFrame:CGRectMake(self.photo.frame.size.width + 10, 10, self.contentView.frame.size.width - self.photo.frame.size.width, 20)];
        [self.contentView addSubview:_title];
        self.pubdate = [[UILabel alloc]initWithFrame:CGRectMake(90, 60, 120, 30)];
        self.pubdate.font = [UIFont systemFontOfSize:10];
        self.pubdate.textColor = [UIColor lightGrayColor];
        
        [self.contentView addSubview:_pubdate];
//        self.photo.backgroundColor = [UIColor greenColor];
//        self.title.backgroundColor = [UIColor yellowColor];
//        self.pubdate.backgroundColor = [UIColor blackColor];
        self.dingyue = [UIButton buttonWithType:UIButtonTypeCustom];
        self.dingyue.frame = CGRectMake(220, 45, 80, 50);
        [self.dingyue setImage:[UIImage imageNamed:@"find_album_unfav_n.png"] forState:UIControlStateNormal];
        
        [self.contentView addSubview:_dingyue];
        
        

    }
    return self;
    
}
-(void)setModel:(SegModel *)model num:(NSInteger)num
{
    
    if (![[[model.list objectAtIndex:num] objectForKey:@"albumCoverUrl290"] isKindOfClass:[NSNull class]])
  {
        
        [self.photo sd_setImageWithURL:[NSURL URLWithString:[[model.list objectAtIndex:num] objectForKey:@"albumCoverUrl290"]] placeholderImage:[UIImage imageNamed:@"123.gif"]];
    }
    self.title.text = [[model.list objectAtIndex:num] objectForKey:@"title"];
    if ([[[model.list objectAtIndex:num] objectForKey:@"lastUptrackAt"] isKindOfClass:[NSNull class]]) {
        
    }
    else
    {
    double num1 = [[[model.list objectAtIndex:num] objectForKey:@"lastUptrackAt"] doubleValue];
    num1 = num1 / 1000;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"YYYY-MM-dd"];
    // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:num1] ;
    
    NSString *Str=[formatter stringFromDate:confromTimesp];
    self.pubdate.text = [NSString stringWithFormat:@"最后更新时间:%@",Str];

    }
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
